﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Badger.Vhdl.Types;

#endregion

namespace Weazel.Badger.Vhdl
{
  public class GezelType
  {
    private bool signed;
    public bool Signed
    {
      get
      {
        return signed;
      }

      set
      {
        signed = value;
      }
    }

    private int width;
    public int Width
    {
      get
      {
        return width;
      }

      set
      {
        width = value;
      }
    }

    public GezelType(bool signed, int width)
    {
      this.width = width;
      this.signed = signed;
    }

    public override string ToString()
    {
      return string.Format("{0}({1})", signed ? "tc" : "ns", width);
    }
  }

  public interface ITypedComponent
  {
    /*
    int Width 
    { 
      get; 
    }
    */

    GezelType GezelType
    {
      get;
    }

    Types.Type Type
    {
      get;
    }

    TypeSet GetPossibleTypes();

		void SetActualType(Entity entity, Process process, Statements.StatementCollection statements, Vhdl.Types.Type type);

    bool VerifyType(ref List<VerifyMessage> messages);
  }

  public abstract class TypedComponent : ITypedComponent
  {
    protected bool verified = false;
    public bool Verified
    {
      get
      {
        return verified;
      }
    }

    protected bool resolved = false;
    public bool Resolved
    {
      get
      {
        return resolved;
      }
    }

    /*
    public int Width
    {
      get
      {
        return type.Width;
      }
    }
    */

    private GezelType gezelType;
    public GezelType GezelType
    {
      get
      {
        return gezelType;
      }

      set
      {
        gezelType = value;
      }
    }


    private Types.Type type = new UndefinedType();
    public Types.Type Type
    {
      get
      {
        return type;
      }

      set
      {
        type = value;
      }
    }

    public TypedComponent(Types.Type type, GezelType gezelType)
    {
      this.type = type;
      this.gezelType = gezelType;
    }

    public abstract TypeSet GetPossibleTypes();
		public abstract void SetActualType(Entity entity, Process process, Statements.StatementCollection statements, Vhdl.Types.Type type);
    public abstract bool VerifyType(ref List<VerifyMessage> messages);
  }
}
